/// @tags:
#include <cstdio>
#include <cstring>
#include <iostream>

using std::cin;
using std::cout;

namespace BlueQuantum {

typedef long long LL;

constexpr int MAXN = 100;

int a[102400];
int p[102400];
bool c[202400];
bool u[102400];

int zz[102400];
int ans[102400];

inline void precalc() {
  memset(c, 0, sizeof(c));
  for (int i = 2; i <= 1000; ++i) {
    if (c[i]) continue;
    int j = i * i;
    while (j <= 200000) {
      c[j] = true;
      j += i;
    }
  }
  p[0] = 0;
  for (int i = 2; i <= 200000; ++i) {
    if (!c[i]) p[++p[0]] = i;
  }
}

void multak(int *a, int k) {
  int j = 0;
  for (int i = 1; i <= a[0]; ++i) {
    j += a[i] * k;
    a[i] = j % 10000;
    j /= 10000;
  }
  while (j) a[++a[0]] = j % 10000, j /= 10000;
}

int modak(int *a, int k) {
  int j = 0;
  for (int i = a[0]; i >= 1; i--) {
    j = (j * 10000 + a[i]) % k;
  }
  return j;
}

void addmul(int *a, int *b, int k) {
  int j = 0;
  if (a[0] < b[0]) a[0] = b[0];
  for (int i = 1; i <= a[0]; ++i) {
    j = j + a[i] + b[i] * k;
    a[i] = j % 10000;
    j /= 10000;
  }
  while (j) a[++a[0]] = j % 10000, j /= 10000;
}

void writelong(int *a) {
  printf("%d", a[a[0]]);
  for (int i = a[0] - 1; i >= 1; i--) {
    printf("%04d", a[i]);
  }
  puts("");
}

int mypow(int a, int k, int p) {
  int ans = 1;
  int j = 1;
  while (j <= k) j <<= 1;
  j >>= 1;
  while (j) {
    ans = (LL)ans * ans % p;
    if (j & k) ans = (LL)ans * a % p;
    j >>= 1;
  }
  return ans;
}

void chineseRestore(int *a, int *p, int n) {
  memset(zz, 0, sizeof(zz));
  memset(ans, 0, sizeof(ans));
  ans[0] = 1;
  zz[0] = 1;
  zz[1] = 1;

  for (int i = 0; i < n; ++i) {
    int m = modak(ans, p[i]);
    int zm = modak(zz, p[i]);
    int t = (LL)mypow(zm, p[i] - 2, p[i]) * ((a[i] - m + p[i]) % p[i]) % p[i];
    addmul(ans, zz, t);
    multak(zz, p[i]);
  }

  writelong(ans);
}

void solve(int n) {
  int s = 0;
  for (int i = 1; i <= p[0]; ++i) {
    if (p[i] + p[i + 1] - 1 > n) {
      s = i - 1;
      break;
    }
  }
  for (int i = 1; i <= s - 1; ++i) {
    a[i] = (p[i] - (p[s] - 1) % p[i]) % p[i];
  }
  a[s] = 0;
  a[s + 1] = (p[s + 1] - (p[s] - 1 - 1) % p[s + 1]) % p[s + 1];
  a[s + 2] = (p[s + 2] - (p[s] * 2 - 1) % p[s + 2]) % p[s + 2];
  memset(u, 0, n * sizeof(*u));
  for (int i = 1; i <= s + 2; ++i) {
    int z = (p[i] - a[i]) % p[i];
    while (z < n) {
      u[z] = true;
      z += p[i];
    }
  }
  int t = s + 3;
  for (int i = 0; i < n; ++i) {
    if (!u[i]) {
      u[i] = true;
      a[t] = (p[t] - (i + 1 - 1) % p[t]) % p[t];
      int z = (p[t] - a[t]) % p[t];
      while (z < n) {
        u[z] = true;
        z += p[t];
      }
      t++;
    }
  }
  chineseRestore(a + 1, p + 1, t - 1);
}

inline int main() {
  precalc();
  int n;
  cin >> n;
  if (n == 1)
    cout << "1";
  else if (n <= 16)
    cout << "No solution";
  else
    solve(n);
  return 0;
}

}  // namespace BlueQuantum

int main() {
#ifndef ONLINE_JUDGE
#ifdef LOCAL
  freopen("/tmp/CodeTmp/testdata.in", "r", stdin);
  freopen("/tmp/CodeTmp/testdata.out", "w", stdout);
#else
  freopen("teleports.in", "r", stdin);
  freopen("teleports.out", "w", stdout);
#endif
#endif

  std::ios::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
  return BlueQuantum::main();
}
